package cn.fansunion.concurrent.threadabc;

import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

//有3个线程ABC。按照ABC来运行（A线程输出A，B线程输出B，C线程输出C，以此类推，循环输出）。
public class ThreadABCTest3 {
	
	private static Lock lock = new ReentrantLock();
	
	public static void main(String[] args) {
		ThreadTask aThread = new ThreadTask("A");
		ThreadTask bThread = new ThreadTask("B");
		ThreadTask cThread = new ThreadTask("C");
		
		for(int index=0;index<10;index++){
			lock.lock();
			aThread.start();
			lock.unlock();
			lock.lock();
			bThread.start();
			lock.unlock();
			lock.lock();
			cThread.start();
			lock.unlock();
		}
	}
	

}
